<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:form>
	<p:panel
		header="#{message.header_consulta_cotacao} - #{message.label_filtro}"
		style="position: relative; left:10%;">
		<h:panelGrid columns="6" style="text-align: right;">

			<h:outputLabel style="margin-left: 30px;"
				value="#{message.label_emissao_de}" />

			<p:inputMask mask="99/99/99" maxlength="8" style="margin-left: 5px;"
				size="12" value="#{consultaCotacaoTela.dataDeFiltro}" />

			<h:outputLabel style="margin-left: 30px;"
				value="#{message.label_emissao_ate}" />

			<p:inputMask mask="99/99/99" maxlength="8" style="margin-left: 5px;"
				size="12" value="#{consultaCotacaoTela.dataAteFiltro}" />

			<h:outputLabel style="margin-left: 30px;"
				value="#{message.label_produto}" />

			<p:inputText style="margin-left: 5px;" size="12"
				value="#{consultaCotacaoTela.codProdFiltro}" />

			<h:outputLabel style="margin-left: 30px;"
				value="#{message.label_descricao}" />

			<p:inputText style="margin-left: 5px;" size="12"
				value="#{consultaCotacaoTela.descProdFiltro}" />

			<h:outputLabel style="margin-left: 30px;"
				value="#{message.label_orcamento_de}" />

			<p:inputText style="margin-left: 5px;" size="12"
				value="#{consultaCotacaoTela.numOrcaDe}" />


			<h:outputLabel style="margin-left: 30px;"
				value="#{message.label_orcamento_ate}" />

			<p:inputText style="margin-left: 5px;" size="12"
				value="#{consultaCotacaoTela.numOrcaAte}" />

			<h:outputLabel value="#{message.label_situacao}" />
			<p:selectOneMenu
				style="text-align: justify; float: left; margin-left:5px;padding-right: 25px;"
				value="#{consultaCotacaoTela.statusFiltro}">
				<f:selectItem itemLabel="Todas" itemValue="TODAS" />
				<f:selectItem itemLabel="Em Aberto" itemValue="ABERTO" />
				<f:selectItem itemLabel="Aprovadas" itemValue="APROVADO" />
				<f:selectItem itemLabel="Encerradas" itemValue="ENCERRADO" />
			</p:selectOneMenu>


		</h:panelGrid>
		<p:commandButton value="#{message.botao_filtrar}"
			action="#{consultaCotacaoTela.filtrarCotacao}"
			update=":formListaCotacao">
		</p:commandButton>
	</p:panel>
</h:form>
<h:form id="formListaCotacao">
	<p:dataTable value="#{consultaCotacaoTela.listaOrcamento}"
		var="orcamento" emptyMessage="#{message.table_empty}"
		style="margin-top:20px; width:950px;" paginator="true" rows="5">

		<p:column style="width:4%">
			<p:rowToggler />
		</p:column>

		<p:column sortBy="#{orcamento.numero}">
			<f:facet name="header">
				<h:outputText value="#{message.label_numero_orcamento}" />
			</f:facet>
			<h:outputText value="#{orcamento.numero}" />
		</p:column>
		<p:column sortBy="#{orcamento.comprador.nome}">
			<f:facet name="header">
				<h:outputText value="#{message.label_comprador}" />
			</f:facet>
			<h:outputText value="#{orcamento.comprador.nome}" />
		</p:column>

		<p:column sortBy="#{orcamento.dataEmissao}">
			<f:facet name="header">
				<h:outputText value="#{message.label_dt_emissao}" />
			</f:facet>
			<h:outputText value="#{orcamento.dataEmissao}">
				<f:convertDateTime pattern="dd/MM/yy" />
			</h:outputText>
		</p:column>

		<p:column sortBy="#{orcamento.dataValidade}">
			<f:facet name="header">
				<h:outputText value="#{message.label_dt_validade}" />
			</f:facet>
			<h:outputText value="#{orcamento.dataValidade}">
				<f:convertDateTime pattern="dd/MM/yy" />
			</h:outputText>
		</p:column>

		<p:rowExpansion>
			<p:dataTable value="#{orcamento.cotacoes}" var="cotacao"
				emptyMessage="#{message.table_empty}"
				style="margin-top:20px; width:600px; margin-left: 30px; margin-bottom: 20px; font-size: 10px;">

				<p:column width="50">

					<f:facet name="header">
						<h:outputText value="#{message.label_produto}" />
					</f:facet>
					<h:outputText value="#{cotacao.itemOrcamento.produto.codigo}" />
				</p:column>
				<p:column width="50">
					<f:facet name="header">
						<h:outputText value="#{message.label_marca}" />
					</f:facet>
					<h:outputText value="#{cotacao.itemOrcamento.produto.marca}" />
				</p:column>
				<p:column width="180">
					<f:facet name="header">
						<h:outputText value="#{message.label_descricao}" />
					</f:facet>
					<h:outputText value="#{cotacao.itemOrcamento.produto.descricao}" />
				</p:column>
				<p:column width="20">
					<f:facet name="header">
						<h:outputText value="UM" />
					</f:facet>
					<h:outputText
						value="#{cotacao.itemOrcamento.produto.unidadeMedida}" />
				</p:column>
				<p:column width="70">
					<f:facet name="header">
						<h:outputText value="#{message.label_valor_uni}" />
					</f:facet>
					<h:outputText value="#{cotacao.valorUnitario}" />
				</p:column>
				<p:column width="70">
					<f:facet name="header">
						<h:outputText value="#{message.label_quantidade}" />
					</f:facet>
					<h:outputText value="#{cotacao.itemOrcamento.quantidade}" />
				</p:column>

				<p:column width="190">
					<f:facet name="header">
						<h:outputText value="#{message.label_forma_pag}" />
					</f:facet>
					<h:outputText
						value="#{cotacao.formaPagamento.formaPag} (#{cotacao.formaPagamento.metodoPag})" />
				</p:column>

				<p:column width="30">
					<f:facet name="header">
						<h:outputText value="#{message.label_frete}" />
					</f:facet>
					<h:outputText value="#{cotacao.tipoFrete}" />
				</p:column>

				<p:column width="80">
					<f:facet name="header">
						<h:outputText value="#{message.label_prazo2}" />
					</f:facet>
					<h:outputText value="#{cotacao.prazoEntrega}" />
				</p:column>

			</p:dataTable>

		</p:rowExpansion>

	</p:dataTable>
</h:form>
</html>